﻿
using System.Collections.Generic;
using System.Data;
using System.ServiceModel;

namespace RemoteTestRunner.Contracts
{
    [ServiceContract]
    public interface IRtrService
    {

        ///// <summary>
        ///// Gets a list of test projects.
        ///// </summary>
        ///// <returns>A <see cref="DataTable"/> containing a list of all test projects.</returns>
        //[OperationContract()]
        //DataTable GetTestProjects();

        ///// <summary>
        ///// Adds a new test.
        ///// </summary>
        ///// <param name="projectId">The Project ID the new test is associated with.</param>
        ///// <param name="name">The name of the new test.</param>
        ///// <returns>A reference to the new test <see cref="DataRow"/>.</returns>
        //[OperationContract(), ServiceKnownType(typeof(DataTable))]
        //int AddTest(int projectId, string name);

        ///// <summary>
        ///// Deletes the specified test.
        ///// </summary>
        ///// <param name="testId">The ID of the test to be deleted.</param>
        //[OperationContract()]
        //void DeleteTest(int testId);

        ///// <summary>
        ///// Gets a list of tests.
        ///// </summary>
        ///// <returns>A <see cref="DataTable"/> containing a list of all tests.</returns>
        //[OperationContract()]
        //DataTable GetTests();

        /// <summary>
        ///   Gets the specified test row.
        /// </summary>
        /// <param name = "testId">The ID of the test to return.</param>
        /// <returns>A <see cref = "DataRow" /> containing the specified test information.</returns>
        [OperationContract]
        TestInfo GetTestRow(int testId);

        /// <summary>
        ///   Gets a collection of data source information.
        /// </summary>
        /// <param name = "appConfigPath">The application configuration file to be parsed.</param>
        /// <returns>A list of <see cref = "DataSourceInfo" /> containing information for each
        ///   data source found in the configuration file.</returns>
        [OperationContract]
        List<DataSourceInfo> GetDataSources(string appConfigPath);

        ///// <summary>
        ///// Gets the test data.
        ///// </summary>
        ///// <returns>A dataset containing the test configuration.</returns>
        //[OperationContract(), ServiceKnownType(typeof(DataSet))]
        //DataSet GetTestData();

        /// <summary>
        ///   Gets the projects.
        /// </summary>
        /// <returns>A List of the projects and tests.</returns>
        [OperationContract]
        List<Project> GetProjects();

        /// <summary>
        ///   Saves the projects.
        /// </summary>
        /// <param name = "projects"></param>
        [OperationContract]
        void SaveProjects(List<Project> projects);

        ///// <summary>
        ///// Saves the test data.
        ///// </summary>
        ///// <param name="dataSet">The data set.</param>
        //[OperationContract()]
        //void SaveTestData(DataSet dataSet);

        /// <summary>
        ///   Gets a list of the classes and methods from the unit test assembly.
        /// </summary>
        /// <param name = "test">The test to process.</param>
        /// <returns>A 2 level hierchial class/method list.</returns>
        [OperationContract, ServiceKnownType(typeof(TestClass)), ServiceKnownType(typeof(TestMethod))]
        List<TestClass> GetTestMethods(Test test);

        /// <summary>
        /// Runs the test for the test ID passed in.
        /// </summary>
        /// <param name="project">The project containing the test to be ran.</param>
        /// <param name="test">The test to be ran.</param>
        /// <param name="testsToRun">A list of the test to run.  The expected format is 'Class.Method'.</param>
        /// <param name="timeoutSeconds">The timeout seconds.</param>
        /// <returns>
        /// The path of the generated test results file.
        /// </returns>
        [OperationContract]
        TestResultSummary RunTest(Project project, Test test, List<string> testsToRun, int timeoutSeconds);

        /// <summary>
        ///   Gets the test result history.
        /// </summary>
        /// <returns></returns>
        [OperationContract]
        List<TestResultSummary> GetTestResultHistory(Project project, Test test);

        /// <summary>
        ///   Deletes the test result history items.
        /// </summary>
        /// <param name = "historyItemsToDelete">The history items to delete.</param>
        [OperationContract]
        void DeleteTestResultHistoryItems(List<TestResultSummary> historyItemsToDelete);

        /// <summary>
        ///   Gets the test result.
        /// </summary>
        /// <param name = "path">The path.</param>
        /// <returns>The results of a test.</returns>
        [OperationContract]
        TestResult GetTestResult(string path);
    }
}